Ext.define('truckplanner.view.contact.List' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.contactlist',

    title : 'Liste des contacts',

    dockedItems: [{
		xtype: 'toolbar',
		items: [{
			text: 'Ajouter...',
			action: 'add'
		},{
			text: 'Editer...',
			disabled: true,
			action: 'edit'
		},{
			text: 'Supprimer',
			disabled: true,
			action: 'remove'
		}
		]
	}],

	store : 'Contacts',
	
	columns : [
            {header: 'Nom',  dataIndex: 'name',  flex: 1},
            {header: 'Prénom', dataIndex: 'firstname', flex: 1},
            {header: 'Role', dataIndex: 'role', flex: 1},
            {header: 'Organisation', dataIndex: 'organizationName', flex: 1},
            {header: 'Email', dataIndex: 'email', flex: 1},
            {header: 'GSM', dataIndex: 'gsm', flex: 1},
            {header: 'Tél', dataIndex: 'phone', flex: 1},
            {header: 'Fax', dataIndex: 'fax', flex: 1}
        ],
	
	listeners: {
	    selectionchange: function(selmode, selection) {
						        var selected = selection[0],
						            button = this.down('button[action=remove]'),
						            button1 = this.down('button[action=edit]');
						        if (selected) {
						            button.enable();
						            button1.enable();
						        }
						        else {
						            button.disable();
						            button1.disable();
						        }
							}
	}
});
